package com.ksd.common.task.start;

import com.ksd.common.schedule.ScheduleManager;
import com.ksd.common.task.PingSiteMapTask;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Slf4j
@Component
public class PingSiteMapTaskStart implements CommandLineRunner {

    @Resource
    private ScheduleManager scheduleManager;
    @Resource
    private PingSiteMapTask pingSiteMapTask;

    @Override
    public void run(String... args) throws Exception {
        log.info("执行定时推送sitemap任务");
        // 从0小时开始，每小时执行一次
        scheduleManager.startTask(pingSiteMapTask, "0 0 0/1 * * ?");
    }
}
